<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/comment.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div id="main">
	<div class="direction" id="direction_div" style="display:none;">
	  	<ul id="direction">
	    	<li id="direction_1" ontouchstart="zy_touch('')" onclick="direction(1);"></li>
	    	<li id="direction_2" ontouchstart="zy_touch('')" onclick="direction(2);"></li>
	    	<li id="direction_3" ontouchstart="zy_touch('')" onclick="direction(3);"></li>
	    	<li id="direction_4" ontouchstart="zy_touch('')" onclick="direction(4);"></li>
	    	<li id="direction_5" ontouchstart="zy_touch('')" onclick="direction(5);"></li>
	  	</ul>
		<span id="direction_txt">点击星星打分</span> 
	</div>
	<div class="textareadiv">
			<textarea id="text" name="text" maxlength="2000" placeholder="请发表8~2000个字节的评论哦~" onkeypress="getRealLen(this.value);" oninput="getRealLen(this.value);"></textarea>
			<em id="words">2000</em> 
	</div>
</div>

</body>
<script>
    	zy_init();
		var strlen=0;
		var _direction =0;
		function direction(k){
			$$('direction').style.backgroundImage = 'url(skin/images/life/'+k+'.png)';
			var txt = {'1':'很差','2':'一般','3':'好','4':'很好','5':'非常好'};
			$$("direction_txt").innerHTML = txt[k];
			_direction = k;
		}

		function getRealLen(str){
    		strlen=str.replace(/[^\x00-\xff]/g,'__').length;
			$$('words').innerHTML=int(2000-strlen);
			$$('text').value=substr(str,2000);
		}
		
		function postdata()
		{
			if (c_l()) {
				var text=trim($$('text').value);
				if(strlen<8){
					uexWindow.alert('','请填写8个字节以上的评论','关闭');return false;
				}
				if(strlen>2000){
					uexWindow.alert('','评论超出2000字节','关闭');return false;
				}
				if(text==''){
					uexWindow.alert('','请输入评论','关闭');return false;
				}
				
				uexWindow.toast(1, 5, '提交中...', 0);
	
				var url = app_path+'index.php?m=iapp&c=app&a=comment';
				uexXmlHttpMgr.open(1,'post',url,"8000");
				uexXmlHttpMgr.setPostData(1,'0','userid',localStorage['u_id']);
				uexXmlHttpMgr.setPostData(1,'0','acctoken',localStorage['u_acctoken']);
				uexXmlHttpMgr.setPostData(1,'0','catid',localStorage['p_catid']);
				uexXmlHttpMgr.setPostData(1,'0','contentid',localStorage['p_id']);
				uexXmlHttpMgr.setPostData(1,'0','title',localStorage['p_title']);
				uexXmlHttpMgr.setPostData(1,'0','url',localStorage['p_url']);
				uexXmlHttpMgr.setPostData(1,'0','id',0);
				uexXmlHttpMgr.setPostData(1,'0','msg',text);
				uexXmlHttpMgr.setPostData(1,'0','direction',_direction);
				uexXmlHttpMgr.send(1);
			}else{
				gologin();	
			}
		}
		
		window.uexOnload=function(type){
			if (!type) {
				
				if(localStorage['p_type']=='company_show'){
					$$('direction_div').style.display = 'block';
				}

				uexXmlHttpMgr.onData = function(opId, status, data){
					uexWindow.closeToast();
					uexXmlHttpMgr.close(opId);
					if (status == 1) {
						data = JSON.parse(data);
						if (data['success'] == 'OK') {
							uexWindow.evaluatePopoverScript(localStorage['p_type'], 'content', 'ok(\'' + data['msg'] + '\')');
							uexWindow.evaluateScript('comment',0,'uexWindow.close(0)');
						}else {
							uexWindow.toast("0", "5", data['msg'], 1000);
						}
					}else if (status == -1) {
						uexWindow.toast("0", "5", "评论提交超时!", 1000);
					}
				}
			}
		}
    </script>
</html>